from concurrent.futures.thread import ThreadPoolExecutor


def fn(name):
    for i in range(1000):
        print(name,i)


if __name__ == '__main__':
    # 创建线程池
    with ThreadPoolExecutor(50) as t:
        for i in range(1000):
            # 将任务提交到线程池
            t.submit(fn, name=f"线程{i}")
    # 等待线程池任务全部执行完毕
    print("123")